import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Meteor is a subclass of Enemy, is not a danguerous enemy.
 * 
 * @author (Arturo Aaron Rios Obregon) 
 * @version (29 june 2013)
 */
public class Meteor extends Enemy
{
    private boolean direccion;
    /**
     * Constructor
     */
    public Meteor()
    {
        super(10);
        direccion = false;
    }    
    
    /**
     * The act method makes move the enemies, check if them touch bullets, create items if them die
     * and eliminate the enemies if his lifes is zero.
     */
    public void act() 
    {
        super.tocaBala();
        super.creaItem();        
        if(direccion==false)
            daDireccion();
        mueve();
        super.vidaCero();

    }
    
    /**
     * Method who gave the actual location of the hero and makes the meteor go there.
     */
    public void daDireccion()
    {
        Hero heroe = ((Juego)getWorld()).getHero();
        turnTowards(heroe.getX(),heroe.getY());
        direccion = true;
    }
    
    /**
     * Redefined method
     * This method move the meteor to the player location when the meteor was created
     */
    public void mueve()
    {
        if(getY()<getWorld().getHeight()&&getX()>0&&getX()<getWorld().getWidth())
            move(1);
        else
            getWorld().removeObject(this);
    }
}
